package com.example.publishDemo.Mapper;

import com.example.publishDemo.Model.Tag;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TagMapper {

    @Select("select * from tag")
    List<Tag> getAll();

    @Select("select * from tag_star where u_id = #{u_id} and t_id = #{t_id}")
    Tag isFocus(int u_id, int t_id);

    @Select("select count(*) from tag_star where t_id = #{t_id}")
    int allPeople(int t_id);

    @Select("select count(*) from articles where tags like concat('%',#{name},'%')")
    int allArticle(String name);

    @Delete("delete from tag_star where u_id = #{u_id} and t_id = #{t_id}")
    int unstar(int u_id, int t_id);

    @Insert("insert into tag_star(u_id,t_id) values(#{u_id},#{t_id})")
    int star(int u_id, int t_id);
}
